package user.zc.excel.data.info;


import user.zc.helper.ExcelAssistant;
import user.zc.excel.data.style.ColumnStyle;
import user.zc.exception.ExcelExceptionEnum;

import java.lang.reflect.Field;

public class ColumnCell implements ICell<Field>{
    @Override
    public CellInfo parse(Field field) {
        ExcelAssistant excelAssistant =  field.getAnnotation(ExcelAssistant.class);
        ExcelExceptionEnum.OBJECT_NOT_EXIST.assertNotNull(excelAssistant);
        CellInfo cellInfo = new CellInfo();
        cellInfo.setData(excelAssistant.title());
        cellInfo.setCellType(CellType.STRING.getValue());
        cellInfo.setMergeRelationColumn(excelAssistant.mergeRelationColumn());
        cellInfo.setStyleInfo(new ColumnStyle().parse(excelAssistant.column()));
        cellInfo.setRowSpanIfSameValue(excelAssistant.rowSpanIfSameValue());
        return cellInfo;
    }
}
